<?php 
/********* Dreamscape ***********/
//Must be included at the top of all included files.
if(!defined('DREAMSCAPE')){die('Sorry, but this file cannot be directly viewed.');} 
include('funcs/rss.class.php');
$rss = new easyRSS;
?>
<!-- Begin page content -->

<h1><?php printf(L_WELCOME_HEADER,DISPLAY_NAME, CMS_NAME); ?></h1>
<div id="summary">
  <?php if (is_unsafe()){ printf(ALERT, L_PERMISSIONS_WARNING);} ?>
  <?php $totals = $auth->getTotals();?>
  <h1><?php printf(L_OVER_TOTAL_USAGE,$totals['user_count'],$totals['total_count']); ?></h1>
    <?php echo  $auth->createSummary(); ?>
  <div id="theBuzz">
    <h1><?php printf(L_LATEST_BUZZ, YOUR_SITE, getOption('sitename')); ?></h1>
    <?php 
			$technorati_url = 'http://feeds.technorati.com/cosmos/rss/?url='.YOUR_SITE;
			if(!isset($_SESSION['remote_buzz'])){
			$sitebuzz = getRemoteFile($technorati_url);
			$buzz = $_SESSION['remote_buzz'] = $rss->parse($sitebuzz->results);
			} else {
			$buzz = $_SESSION['remote_buzz'];
			}
			$has_buzz = (count($buzz['items']) > 1 && !empty($buzz['items'][0]['link']));
			$no_buzz = '<h2>'.sprintf(L_NO_BUZZ, COMPANY_URL, CMS_NAME).'</h2>';
			if(!empty($buzz['items'])){
			foreach($buzz['items'] as $ind => $val){ 
				if($ind < 9){
					$title = $val['title'];
					$descr = (strlen($val['description']) > 330) ? substr($val['description'], 0, 330)."..." : $val['description'];
					$link = $val['link'];
					if(!$has_buzz){
					echo $no_buzz;
					break;
					}
			?>
    <h2><a class="buzz" href="<?php echo $link ?>" target="_blank" title="<?php echo strip_tags($descr) ?>"><?php echo $title ?></a></h2>
    <?php 
				}
				}
			} else {
			echo  $no_buzz;
			}
				?>
  </div>
</div>
<div id="dreamscapeNews">
  <h1><?php printf(L_LATEST_NEWS, CMS_NAME)?></h1>
  <?php 
			$news = array('items'=>array());
			if(!isset($_SESSION['remote_news'])){
			$dreamscapeRSS = getRemoteFile(DREAMSCAPE_NEWS_URL);
			$news = $_SESSION['remote_news'] = $rss->parse($dreamscapeRSS->results, "Y-m-d H:i:s");
			} else {
			$news = $_SESSION['remote_news'];
			}
			
			
			foreach($news['items'] as $ind => $val){ 
				if($ind < 3){
					$title = $val['title'];
					$link = $val['link'];
					$descr = (strlen($val['description']) > 150) ? substr($val['description'], 0, 150).'&hellip; <a href="'.$link.'" target="_blank">[More]</a>' : $val['description'];
					$date = date('F jS, Y // g.i a', strtotime($val['pubDate']));
			?>
  <h2><a href="<?php echo $link ?>" target="_blank"><?php echo $title ?></a></h2>
  <h3><?php echo $date ?></h3>
  <?php echo $descr ?>
  <?php 
				}
	}
echo empty($news['items']) ? L_NEWS_NOT_LOADING : '';
				 ?>
</div>



<!-- End page content -->

